<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Noto Serif SC:300,300italic,400,400italic,700,700italic|Source Code Pro:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"example.com","root":"/","scheme":"Pisces","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":true,"show_result":true,"style":"flat"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="12let someString &#x3D; &quot;some string literal value&quot; + &quot;other string&quot;  多行字符串 12345let multiline &#x3D; &quot;&quot;&quot;one line two line&quot;&quot;&quot;  如果你只是想换行让文本更易读，而不是想在字符串">
<meta property="og:type" content="article">
<meta property="og:title" content="String">
<meta property="og:url" content="http://example.com/2018/12/21/Swift/String/index.html">
<meta property="og:site_name" content="HR&#39;s Blog">
<meta property="og:description" content="12let someString &#x3D; &quot;some string literal value&quot; + &quot;other string&quot;  多行字符串 12345let multiline &#x3D; &quot;&quot;&quot;one line two line&quot;&quot;&quot;  如果你只是想换行让文本更易读，而不是想在字符串">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://www.caohr.com/ImagesFolder/15299025228972.jpg">
<meta property="og:image" content="http://www.caohr.com/ImagesFolder/15299025413274.jpg">
<meta property="og:image" content="http://www.caohr.com/ImagesFolder/15299025575243.jpg">
<meta property="article:published_time" content="2018-12-21T07:12:43.000Z">
<meta property="article:modified_time" content="2018-12-21T07:12:43.000Z">
<meta property="article:author" content="HR">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://www.caohr.com/ImagesFolder/15299025228972.jpg">

<link rel="canonical" href="http://example.com/2018/12/21/Swift/String/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'en'
  };
</script>

  <title>String | HR's Blog</title>
  
    <script async src="https://www.googletagmanager.com/gtag/js?id=UA-61905451-1"></script>
    <script>
      if (CONFIG.hostname === location.hostname) {
        window.dataLayer = window.dataLayer || [];
        function gtag(){dataLayer.push(arguments);}
        gtag('js', new Date());
        gtag('config', 'UA-61905451-1');
      }
    </script>






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">HR's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Swimming 🏊 in the sea🌊of code!</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>Home</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>About</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>Tags</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>Categories</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>Archives</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="en">
    <link itemprop="mainEntityOfPage" href="http://example.com/2018/12/21/Swift/String/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="HR">
      <meta itemprop="description" content="Swimming 🏊 in the sea🌊of code!">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="HR's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          String
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2018-12-21 15:12:43" itemprop="dateCreated datePublished" datetime="2018-12-21T15:12:43+08:00">2018-12-21</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">In</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Swift/" itemprop="url" rel="index"><span itemprop="name">Swift</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">let someString &#x3D; &quot;some string literal value&quot; + &quot;other string&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>多行字符串</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">let multiline &#x3D; &quot;&quot;&quot;</span><br><span class="line">one line </span><br><span class="line">two line</span><br><span class="line">&quot;&quot;&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>如果你只是想换行让文本更易读，而不是想在字符串中真正的换行可以在要换行的地方加上<code>\</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">let str1 &#x3D; &quot;&quot;</span><br><span class="line">let str2 &#x3D; &quot; &quot;</span><br><span class="line"></span><br><span class="line">let value &#x3D; str1.isEmpty  &#x2F;&#x2F;true</span><br><span class="line">let value2 &#x3D; str2.isEmpty  &#x2F;&#x2F;false</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<span id="more"></span>

<h3 id="Characters"><a href="#Characters" class="headerlink" title="Characters"></a>Characters</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">for character in &quot;Dog!狗&quot; &#123;</span><br><span class="line">    print(character)</span><br><span class="line">&#125;</span><br><span class="line">D  o g ! 🐶</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">let exclamationMark: Character &#x3D; &quot;!&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="Grapheme-Clusters"><a href="#Grapheme-Clusters" class="headerlink" title="Grapheme Clusters"></a>Grapheme Clusters</h3><p><img src="http://www.caohr.com/ImagesFolder/15299025228972.jpg"><br><img src="http://www.caohr.com/ImagesFolder/15299025413274.jpg"></p>
<p>通常在OC中我们访问相应位置的字符使用Int类型像数组一样就可以访问，但是针对于特别的情况OC中就显得力不从心，例如像e带音节，单独的e带音节是233，但是也有分开单独e字幕加音节，他们显示的东西完全是相同的，再者像Emoji表情，里面包含皮肤的Emoji其实也是由有个字符组合一起显示的效果。这个时候直接使用OC的int类型来访问字符，或者计算字符的总长度就会出问题。（oc中可能认为第二种情况的e是两个字符）</p>
<p>但是在swift中用.count访问他们的时候，swift会认为只是一个字符，不管你用什么方式输入e加音节这个字符。而且上图的emoji表情，swift count的结果也是认为只是一个字符。因为这些改动导致，swfit的获取子字符串的range就变得和OC不一样了。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">let cafeNormal &#x3D; &quot;café&quot;</span><br><span class="line">let cafeCombining &#x3D; &quot;cafe\u&#123;0301&#125;&quot;</span><br><span class="line"></span><br><span class="line">cafeNormal.count &#x2F;&#x2F;4</span><br><span class="line">cafeCombining.count &#x2F;&#x2F;4</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="获取实际字符数量。"><a href="#获取实际字符数量。" class="headerlink" title="获取实际字符数量。"></a>获取实际字符数量。</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">cafeNormal.unicodeScalars.count &#x2F;&#x2F;4</span><br><span class="line">cafeCombining.unicodeScalars.count &#x2F;&#x2F;5</span><br><span class="line">&#x2F;&#x2F;遍历</span><br><span class="line">for codePoint in cafeCombining.unicodeScalars &#123;</span><br><span class="line">    print(codePoint.value)</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;99 97 102 101 769</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="Indexing-Strings"><a href="#Indexing-Strings" class="headerlink" title="Indexing Strings"></a>Indexing Strings</h3><p>直接传入Int值来取Swift的字符串会报错。你必须使用特殊的<code>Index type</code>来操作Strings字符串。例如代表字符串的起始位置</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">let firstIndex &#x3D; cafeCombining.startIndex</span><br><span class="line">let firstChar &#x3D; cafeCombining[firstIndex]</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>同理如果你要取得最后一个字符</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">let lastIndex &#x3D; cafeCombining.endIndex</span><br><span class="line">let lastChar &#x3D; cafeCombining[lastIndex]</span><br><span class="line"></span><br><span class="line">&#x2F;&#x2F;你会得到一个错误的提示fatal error: Can&#39;t form a Character from an empty String</span><br><span class="line">&#x2F;&#x2F;因为endIndex获取的位置是字符串的末尾，末尾以后没有字符串，所以提示错误</span><br><span class="line"></span><br><span class="line">let lastIndex &#x3D; cafeCombining.index(before: cafeCombining.endindex)</span><br><span class="line">let lastChar &#x3D; cafeCombining[lastIndex]</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>offset from the first character</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">let fourthIndex &#x3D; cafeCombining.index(cafeCombining.startIndex, offsetBy:3)</span><br><span class="line">let fourthChar &#x3D; cafeCombining[fourthIndex] &#x2F;&#x2F;得到é</span><br><span class="line"></span><br><span class="line">这个é其实是两个编码组成的，所以&#96;fourthChar.unicodeScalars.count&#96;会等于2.</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="combining-characters字符串的相等问题"><a href="#combining-characters字符串的相等问题" class="headerlink" title="combining characters字符串的相等问题"></a>combining characters字符串的相等问题</h3><p><img src="http://www.caohr.com/ImagesFolder/15299025575243.jpg"><br>其他语言里 认为这两个字符串是不相等，但是他们其实现实的字符是一样的，但是在Swift里面认为他们是相等的，原理就是swift里面使用了一种<code>canonicalization</code>的技术，而且会三倍速度的提升比起之前的检测相等。其实在swift内部就是把字符串统一称为一种然后再做比较。</p>
<h3 id="String-as-bi-directional-collections"><a href="#String-as-bi-directional-collections" class="headerlink" title="String as bi-directional collections."></a>String as bi-directional collections.</h3><p>反向字符串Swift直接提供了<code>reversed()</code>方法，但是返回的不是<code>String</code>类型而是<code>reversed colletion</code>类型。这其实是一种机制的方法，这种类型直接引用字符串的地址，而不是重新创建他们。</p>
<p>但是如果我想获得String类型怎么办？swift提供了以下方法。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">let backwardsNameString &#x3D; String(backwardsName) &#x2F;&#x2F;这样介绍了在原来的字符串上反响引用，而为你的字符串申请了新的内存地址。</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h3 id="SubStrings字符串"><a href="#SubStrings字符串" class="headerlink" title="SubStrings字符串"></a>SubStrings字符串</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">let fullName &#x3D; &quot;Matt Galloway&quot;</span><br><span class="line">let spaceIndex &#x3D; fullName.index(of: &quot; &quot;)!</span><br><span class="line">let firstName &#x3D; fullName[fullName.startIndex..&lt;spaceIndex] &#x2F;&#x2F; &quot;Matt”</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>以上的代码中<code>firstName</code>也和<code>reversed</code>方法一样只是提供在原始字符串上的引用。而你得到的<code>firstName</code>也不是直接的<code>String</code>类型，而是基本上功能和<code>String</code>一样的<code>SubString</code>。这样也同样为了节省内存。如果要获得字符串结束在原有的字符串上的引用。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">let lastNameString &#x3D; String(lastName)</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<h2 id="Encoding"><a href="#Encoding" class="headerlink" title="Encoding"></a>Encoding</h2><p>见HTTP里面的UTF-8</p>
<h2 id="Range表示一个范围"><a href="#Range表示一个范围" class="headerlink" title="Range表示一个范围"></a>Range表示一个范围</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">let underFive &#x3D; 0.0..&lt;5.0</span><br><span class="line">underFive.contains(3.14)  &#x2F;&#x2F; true</span><br><span class="line">underFive.contains(6.28) &#x2F;&#x2F; false</span><br><span class="line">underFive.contains(5.0)  &#x2F;&#x2F; false</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">for n in 3..&lt;5 &#123;</span><br><span class="line">    print(n)</span><br><span class="line">&#125;</span><br><span class="line">&#x2F;&#x2F; Prints &quot;3&quot;</span><br><span class="line">&#x2F;&#x2F; Prints &quot;4&quot;</span><br><span class="line"></span><br></pre></td></tr></table></figure>

<p>“Working with Cocoa Data Types in Using Swift with Cocoa and Objective-C”</p>
<p>Excerpt From: Apple Inc. “The Swift Programming Language (Swift 4.1).” iBooks.</p>
<p><a target="_blank" rel="noopener" href="https://stackoverflow.com/questions/39677330/how-does-string-substring-work-in-swift">https://stackoverflow.com/questions/39677330/how-does-string-substring-work-in-swift</a></p>

    </div>

    
    
    
        

  <div class="followme">
    <p>Welcome to my other publishing channels</p>

    <div class="social-list">

        <div class="social-item">
          <a target="_blank" class="social-link" href="/atom.xml">
            <span class="icon">
              <i class="fa fa-rss"></i>
            </span>

            <span class="label">RSS</span>
          </a>
        </div>
    </div>
  </div>


      <footer class="post-footer">

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2018/12/21/Swift/Swift%20Tip%20Notifications/" rel="prev" title="Swift Tip: Notifications">
      <i class="fa fa-chevron-left"></i> Swift Tip: Notifications
    </a></div>
      <div class="post-nav-item">
    <a href="/2018/12/21/Swift/Singleton/" rel="next" title="Singleton">
      Singleton <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#Characters"><span class="nav-number">1.</span> <span class="nav-text">Characters</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Grapheme-Clusters"><span class="nav-number">2.</span> <span class="nav-text">Grapheme Clusters</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#%E8%8E%B7%E5%8F%96%E5%AE%9E%E9%99%85%E5%AD%97%E7%AC%A6%E6%95%B0%E9%87%8F%E3%80%82"><span class="nav-number">3.</span> <span class="nav-text">获取实际字符数量。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Indexing-Strings"><span class="nav-number">4.</span> <span class="nav-text">Indexing Strings</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#combining-characters%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%9A%84%E7%9B%B8%E7%AD%89%E9%97%AE%E9%A2%98"><span class="nav-number">5.</span> <span class="nav-text">combining characters字符串的相等问题</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#String-as-bi-directional-collections"><span class="nav-number">6.</span> <span class="nav-text">String as bi-directional collections.</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#SubStrings%E5%AD%97%E7%AC%A6%E4%B8%B2"><span class="nav-number">7.</span> <span class="nav-text">SubStrings字符串</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Encoding"><span class="nav-number"></span> <span class="nav-text">Encoding</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Range%E8%A1%A8%E7%A4%BA%E4%B8%80%E4%B8%AA%E8%8C%83%E5%9B%B4"><span class="nav-number"></span> <span class="nav-text">Range表示一个范围</span></a></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">HR</p>
  <div class="site-description" itemprop="description">Swimming 🏊 in the sea🌊of code!</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">38</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">9</span>
        <span class="site-state-item-name">categories</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">tags</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="mailto:caohr@outlook.com" title="E-Mail → mailto:caohr@outlook.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">HR</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a>
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
